package edu.ynu.hhy.architectureclass.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import edu.ynu.hhy.architectureclass.common.entity.LogicEntity;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Set;

@Getter
@Setter
@Entity
@Where(clause = "is_deleted = 0")
public class CameraData extends LogicEntity {
    @Column(name = "device_serial", nullable = false) // 确保列名与数据库一致
    private String deviceSerial; // 设备的序列号

    private String picUrl;       // 抓拍图片的 URL

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "device_serial", referencedColumnName = "serial_number", insertable = false, updatable = false)
    @JsonIgnoreProperties("cameraData")
    private Device device; // 关联的设备


//    @Temporal(TemporalType.TIMESTAMP)
//    @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
//    private LocalDateTime createTime; // 创建时间
//
//    @Temporal(TemporalType.TIMESTAMP)
//    @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
//    private LocalDateTime updateTime; // 创建时间

    @Override
    public String toString() {
        return "CameraData{" +
                "id=" + getId() +
                ", deviceSerial='" + deviceSerial + '\'' +
                ", picUrl='" + picUrl + '\'' +
                ", createTime=" + getCreateTime() +
                ", updateTime=" + getUpdateTime() +
                ", isDeleted=" + getIsDeleted() +
                '}';
    }
}
